#ifndef __WIZ_FILE_HPP__SHANHAOBO_19800429__
#define __WIZ_FILE_HPP__SHANHAOBO_19800429__

#include "../../Base/WizBase.hpp"
#include "../../Core/Container/WizDataTypeBuffer.hpp"

namespace Wiz
{
    namespace File
    {
        //////////////////////////////////////////////////////////////////////////

        WIZ_DECLARE_PTR(::FILE);

        //////////////////////////////////////////////////////////////////////////

        namespace OpenOptions
        {
            enum ____
            {
                eOpenRead   =   WIZ_BITS_DEF(0),
                eOpenWrite  =   WIZ_BITS_DEF(1),
                eOpenCreate =   WIZ_BITS_DEF(2),
            };
        } /// end of namespace OpenOptions

        WIZ_INLINE ::Wiz::File::Ptr     Open(
            ::Wiz::String::In,
            ::Wiz::UInt::In OpenOpts = ::Wiz::File::OpenOptions::eOpenRead | ::Wiz::File::OpenOptions::eOpenWrite | ::Wiz::File::OpenOptions::eOpenCreate
            );
        WIZ_INLINE ::Wiz::Void::Type    Close(::Wiz::File::Ptr);

        WIZ_INLINE ::Wiz::Bool::Type    Read(::Wiz::File::Ptr, ::Wiz::Byte::OutPtr, ::Wiz::Int64::In);
        WIZ_INLINE ::Wiz::Bool::Type    Write(::Wiz::File::Ptr, ::Wiz::Byte::InPtr, ::Wiz::Int64::In);

        WIZ_INLINE ::Wiz::Bool::Type    ReadAndAdvance(::Wiz::File::Ptr, ::Wiz::Byte::OutPtr, ::Wiz::Int64::In);
        WIZ_INLINE ::Wiz::Bool::Type    WriteAndAdvance(::Wiz::File::Ptr, ::Wiz::Byte::InPtr, ::Wiz::Int64::In);

        WIZ_INLINE ::Wiz::USize32::Type   CurrentPosition(::Wiz::File::Ptr);
        WIZ_INLINE ::Wiz::Void::Type    MoveTo(::Wiz::File::Ptr, ::Wiz::Int64::In);
        WIZ_INLINE ::Wiz::Void::Type    MoveToBegin(::Wiz::File::Ptr);
        WIZ_INLINE ::Wiz::Void::Type    MoveToEnd(::Wiz::File::Ptr);
        WIZ_INLINE ::Wiz::Void::Type    Move(::Wiz::File::Ptr, ::Wiz::Int64::In);
        WIZ_INLINE ::Wiz::Void::Type    Expend(::Wiz::File::Ptr, ::Wiz::Byte::InPtr, ::Wiz::Int64::In);

        ::Wiz::Bool::Type               Exist(::Wiz::String::In);
        ::Wiz::Bool::Type               CreateEmptyFile(::Wiz::String::In);

        //////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////////

        ::Wiz::Bool::Type ReadFileToBuffer(::Wiz::ByteBuffer::Out, ::Wiz::String::In);
        ::Wiz::Bool::Type WriteBufferToFile(::Wiz::ByteBuffer::In, ::Wiz::String::In);

        //////////////////////////////////////////////////////////////////////////

        namespace LargeFileTask
        {
            struct Type : ::Wiz::ByteBuffer::Type
            {
                typedef ::Wiz::ByteBuffer::Type tSuper;
                enum
                {
                    eMaxSize = 50 * 1024 * 1024
                };
            public:
                Type()
                    : tSuper(eMaxSize)
                    , m_CurrentPosition(0)
                    , m_TotalLength(0)
                    , m_Availability(0)
                    , m_MaxSize(eMaxSize)
                    , m_StreamHandler(WIZ_NULLPTR)
                {
                }
                Type(::Wiz::UInt::In MaxCap)
                    : tSuper(MaxCap)
                    , m_CurrentPosition(0)
                    , m_TotalLength(0)
                    , m_Availability(0)
                    , m_MaxSize(MaxCap)
                    , m_StreamHandler(WIZ_NULLPTR)
                {
                }
            public:
                ::Wiz::Int64::Type  m_CurrentPosition;
                ::Wiz::Int64::Type  m_TotalLength;
                ::Wiz::Int64::Type  m_MaxSize;
                ::Wiz::Int64::Type  m_Availability;
            public:
                ::Wiz::File::Ptr    m_StreamHandler;
            };
            WIZ_DECLARE(::Wiz::File::LargeFileTask::Type);

            //////////////////////////////////////////////////////////////////////////
            ::Wiz::Bool::Type Initialize(::Wiz::File::LargeFileTask::Out, ::Wiz::String::In);
            ::Wiz::Bool::Type Read(::Wiz::File::LargeFileTask::InOut);
            ::Wiz::Bool::Type Write(::Wiz::File::LargeFileTask::InOut);
        } /// end of namespace LargeFileTask
        //////////////////////////////////////////////////////////////////////////
    } /// end of namespace File
} /// end of namespace Wiz

#ifndef __WIZ_FILE_INL__SHANHAOBO_19800429__
#define __WIZ_FILE_INL__SHANHAOBO_19800429__
#include "./WizFile.inl"
#endif /*__WIZ_FILE_INL__SHANHAOBO_19800429__*/

#endif /*__WIZ_FILE_HPP__SHANHAOBO_19800429__*/
